<template>
	<view class="container">
		<view class="form-box">
			<text class="title">登录</text>
			<input class="input" placeholder="请输入用户名" v-model="username" />
			<input class="input" placeholder="请输入密码" password v-model="password" />
			<navigator url="/pages/cardViewPage/MinePage/MinePage">
				<button class="btn" @click="login()">登录</button>
			</navigator>
			<navigator url="/pages/Register/Register" class="link-text">
				没有账号？去注册
			</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: ''
			};
		},
		methods: {
			login() {
				// 模拟登录验证（实际需调用后端接口）
				if (this.username && this.password) {
					// 保存用户信息到缓存
					uni.setStorageSync('userInfo', {
						username: this.username
					});
					// 登录成功后，返回“我的”页面（标准处理：记录目标页面+redirectTo）
					uni.redirectTo({
						url: "/pages/cardViewPage/MinePage/MinePage" // 你的“我的”页面路径
					});
				}
			}
		}
	}
</script>

<style>
	.container {
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #f8f8f8;
	}

	.form-box {
		width: 80%;
		max-width: 400px;
		padding: 20px;
		background-color: #fff;
		border-radius: 10px;
		box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
	}

	.title {
		font-size: 24px;
		margin-bottom: 20px;
		text-align: center;
	}

	.input {
		width: 100%;
		padding: 10px;
		margin-bottom: 15px;
		border: 1px solid #ddd;
		border-radius: 5px;
	}

	.btn {
		width: 100%;
		padding: 10px;
		background-color: #007aff;
		color: #fff;
		border: none;
		border-radius: 5px;
		font-size: 16px;
		margin-top: 10px;
	}

	.link-text {
		display: block;
		text-align: center;
		margin-top: 15px;
		color: #007aff;
	}
</style>